package com.tvunetworks.center.device.util;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.tvunetworks.center.common.util.CallerBlocksPolicy;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 *
 *
 * 公用连接池
 *
 * @program:
 * @description:
 * @author HenryChen
 * @create: 5/14/2019 2:50 PM
 **/
public class ThreadPoolUtil {


    /**
     *  此线程池主要在 service 层中使用进行业务处理
     */
    public static  final  ExecutorService SERVICETHREADPOOL = new ThreadPoolExecutor(
            5,
            100,
            60L, TimeUnit.SECONDS,
            new ArrayBlockingQueue(10), new ThreadFactoryBuilder()
            .setNameFormat("Device-Service-ThreadPool-%d")
            .setDaemon(true)
            .build(),
            new CallerBlocksPolicy(Long.MAX_VALUE));
}
